package mipushdemo.xiaomi.com.diyitonghang.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import mipushdemo.xiaomi.com.diyitonghang.R;
import mipushdemo.xiaomi.com.diyitonghang.data.bean.HomeDataBean;
import mipushdemo.xiaomi.com.diyitonghang.data.bean.SearchBean;

public class SearchRecyAdapter extends BaseMultiItemQuickAdapter<SearchBean.DataBean.NewListBean,BaseViewHolder> {

    public SearchRecyAdapter(List<SearchBean.DataBean.NewListBean> data) {
        super(data);
        addItemType(0, R.layout.zero_home_item);
        addItemType(1, R.layout.one_home_item);
        addItemType(2, R.layout.two_home_item);
        addItemType(3, R.layout.three_home_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, SearchBean.DataBean.NewListBean item) {
        List<String> list = item.getImageListThumb();
        helper.addOnClickListener(R.id.iv_delete);
        switch (helper.getItemViewType()) {
            case 0:
                helper.setText(R.id.home_item_title,item.getTitle());
                helper.setText(R.id.home_item_origin,item.getOrigin());
                helper.setText(R.id.home_item_date,item.getPublishTime());
                helper.setText(R.id.home_item_readCount,"阅读:"+item.getPageviews());
                break;
            case 1:
                helper.setText(R.id.home_item_title,item.getTitle());
                helper.setText(R.id.home_item_origin,item.getOrigin());
                helper.setText(R.id.home_item_date,item.getPublishTime());
                helper.setText(R.id.home_item_readCount,"阅读:"+item.getPageviews());
                Glide.with(mContext).load(list.get(0)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img));
                break;
            case 2:
                helper.setText(R.id.home_item_title,item.getTitle());
                helper.setText(R.id.home_item_origin,item.getOrigin());
                helper.setText(R.id.home_item_date,item.getPublishTime());
                helper.setText(R.id.home_item_readCount,"阅读:"+item.getPageviews());
                Glide.with(mContext).load(list.get(0)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img));

                break;
            case 3:
                helper.setText(R.id.home_item_title,item.getTitle());
                helper.setText(R.id.home_item_origin,item.getOrigin());
                helper.setText(R.id.home_item_date,item.getPublishTime());
                helper.setText(R.id.home_item_readCount,"阅读:"+item.getPageviews());
                Glide.with(mContext).load(list.get(0)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img));
            Glide.with(mContext).load(list.get(1)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img2));
            Glide.with(mContext).load(list.get(2)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img3));
                break;
        }
//
//
//
//
//        int isTop = item.getIsTop();
//        String top;
//        if(isTop == 0){
//            top = "不置顶";
//        }else{
//            top = "置顶";
//        }
//        helper.setText(R.id.home_item_zhiDing0,top);
//        helper.setText(R.id.home_item_zhiDing1,top);
//        helper.setText(R.id.home_item_zhiDing2,top);
//        helper.setText(R.id.home_item_zhiDing3,top);
//        if(list.size() == 3){
//            Glide.with(mContext).load(list.get(0)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img31));
//            Glide.with(mContext).load(list.get(1)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img32));
//            Glide.with(mContext).load(list.get(2)).placeholder(R.drawable.ic_image_loading).error(R.drawable.ic_empty_picture).into((ImageView) helper.getView(R.id.home_item_img33));
//        }else{
//        }
    }
}
